// -*-mode:c++; coding:utf-8-*-

#ifndef _XBASE_TABLE_SCHEMA_MANAGER_HPP_
#define _XBASE_TABLE_SCHEMA_MANAGER_HPP_

#include <map>

#include <xthread/read_write_lock.hpp>
#include <xthread/guard.hpp>

#include "table_schema.hpp"

namespace xbase
{
	class table_schema_manager
	{
	public:
		// table name -> table schema
		typedef std::map<std::string, table_schema::pointer> schema_map;

	public:

		bool update_or_add(table_schema::pointer p_schema);

		table_schema::pointer get_schema(const std::string &p_table_name);

	private:
		schema_map m_schemas;
		ReadWriteLock m_schemas_lock;

	};

} // namespace xbase

#endif	// _XBASE_TABLE_SCHEMA_MANAGER_HPP_
